package com.yixun.qfbao.api.service.impl;

import com.yixun.qfbao.api.service.PremisesAndCaseMemberService;
import com.yixun.qfbao.apidto.StaffPremiseRelReqDto;
import com.yixun.qfbao.mapper.PartnerInfoMapper;
import com.yixun.qfbao.xf.model.enums.PremisesStatusEnum;
import com.yixun.qfbao.xf.model.enums.SaleStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author zilong.liu
 * @date  2020-7-23 
 * @desc
 * 		对案场人员和楼盘进行查询或者操作
 */
@Service
public class PremisesAndCaseMemberServiceImpl implements PremisesAndCaseMemberService{
	
	@Autowired
	PartnerInfoMapper partnerInfoMapper;

	/**
	 *  获取员工的驻场楼盘信息并返回
	 */
	@Override
	public List<Map<String, Object>> getPremisesAndCaseMemberByStaffId(
			StaffPremiseRelReqDto staffPremiseRelReqDto) {
		Map<String, Object> params = new HashMap<>();
		params.put("partnerId", staffPremiseRelReqDto.getPartnerId());
		params.put("provId", staffPremiseRelReqDto.getProvId());
		params.put("cityId", staffPremiseRelReqDto.getCityId());
		params.put("areaId", staffPremiseRelReqDto.getAreaId());
		params.put("premisesName", staffPremiseRelReqDto.getPremisesName());
		params.put("saleStatus", staffPremiseRelReqDto.getSaleStatus());
		params.put("premisesStatus", staffPremiseRelReqDto.getPremisesStatus());
		List<Map<String, Object>> caseAndPremisesList =	partnerInfoMapper.getPremisesAndCaseMemberByStaffId(params);
		for (Map<String, Object> caseAndPremises : caseAndPremisesList) {
			caseAndPremises.put("saleStatusName",
					SaleStatusEnum.getSalesByNo(String.valueOf(caseAndPremises.get("saleStatus"))));
			caseAndPremises.put("premisesStatusName", 
					PremisesStatusEnum.getByNo(String.valueOf(caseAndPremises.get("premisesStatus"))).getDes());
		}
		return caseAndPremisesList;
	}

}
